package com.junjiao.util.search;

import java.util.List;

import org.apache.lucene.document.Document;

/**
 * 
 * 查询结果集:供lucene查询索引装载结果集所用
 *
 * @author jiaojun
 *
 */
public class SearchResult {
	
	/**
	 * 查询结果集
	 */
	public List<Document> documents;
	
	/**
	 * 总记录数
	 */
	public int totalCount;
	
	/**
	 * 总页数
	 */
	public int totalPage;
	
	/**
	 * 每页记录数
	 */
	public int pageSize;
	
	/**
	 * 当前页数
	 */
	public int currentPage;

	public List<Document> getDocuments() {
		return documents;
	}

	public void setDocuments(List<Document> documents) {
		this.documents = documents;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
		countMaxPage();
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	private void countMaxPage() {
			if (totalCount % (int) pageSize == 0L)
				totalPage = totalCount / pageSize;
			else
				totalPage = totalCount / pageSize + 1;
			setTotalPage(totalPage);
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	
}
